from ftplib import FTP

class myFTP:
    def __init__(self,host,user,password):
        self.m_ftp = FTP()
        self.m_ftp.connect(host)
        self.m_ftp.login(user,password)
        
    def __del__(self):
        self.m_ftp.quit()
        
    def getFile(self,srcfile,dstfile):
        self.m_ftp.retrbinary('RETR '+srcfile,open(dstfile,'wb').write)

    def putFile(self,srcfile,dstfile):
        self.m_ftp.storbinary('STOR '+dstfile,open(srcfile,"rb"))

if __name__ == '__main__':
    myftp = myFTP("192.168.0.12","huchenkai","huchenkai")
    myftp.getFile("cfg.ini","cfg.ini")
    myftp.putFile("xxxx.ini","xxxx.ini")